<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="/static/js/common/jquery.js"></script>
    <title>填写支付宝信息</title>
    <script src="/static/js/putForward/common.js"></script>
    <script src="/static/js/util.js"></script>
    <script src="/static/js/init.js"></script>
    <script src="/static/js/common/flexible.js"></script>
    <link rel="stylesheet" href="/static/css/putForward/common.css">
    <link rel="stylesheet" href="/static/css/putForward/zfbaccount.css">

    <style>
        html,body{-webkit-text-size-adjust: 100%;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);}
    </style>
</head>
<body>
<script src="/static/js/Monitor.js"></script>
<div class="zfbforward">
    <div class="zfb-sum">
        <b>支付宝姓名</b>
        <input class="zfbinfo" id="zfbname" type="text" placeholder="请输入真实姓名">
        <span class="hide dismiss" >×</span>
    </div>
    <div class="zfb-sum">
        <b>支付宝账号</b>
        <input class="zfbinfo" id="zfbele" type="text" placeholder="请输入支付宝账号">
        <span class="hide dismiss" >×</span>
    </div>
    <p>温馨提示：支付宝账户和姓名要匹配，否则无法到账</p>
    <div class="apply a-color" id="complete">完成</div>
</div>
<div class="message hide" id="message"><span>请输入完整提现信息！</span></div>
<script>
    var capitalAccount = null;
    $(function () {
        initUser();
        refreshCapitalAccount();
        if(userobj.accountName || userobj.accountNo){
            $("#zfbname").val(userobj.accountName);
            $("#zfbele").val(userobj.accountNo);
        }
        //判断input输入框
        $(".zfbinfo").on("input",function () {
            var name=$(this).val();
            if(name){
                $(this).siblings("span").removeClass("hide");
            }else{
                $(this).siblings("span").addClass("hide");
            }
        });
        $(".dismiss").click(function () {
            $(this).siblings(".zfbinfo").val("");
            $(this).addClass("hide");
        });
        //点击提交
        $("#complete").click(function () {
            var zfbname=$("#zfbname").val();
            var zfbNo=$("#zfbele").val();
            if(zfbname==""){
                $("#message>span").html("请输入姓名");
                $("#message").removeClass("hide");
                setTimeout(function () {
                    $("#message").addClass("hide");
                },2000);
            }else if(zfbNo==""){
                $("#message>span").html("请输入账户");
                $("#message").removeClass("hide");
                setTimeout(function () {
                    $("#message").addClass("hide");
                },2000);
            }else{
                var accountName = $("#zfbname").val();
                var accountNo = $("#zfbele").val();
                $.ajax({
                    url:genUrl("/wallet/setCapitalAccount"),
                    type: 'POST',
                    dataType:'json',
                    async:true,
                    headers:{
                        "x-access-id": userobj.accessId,
                        "x-access-token": userobj.accessToken,
                        "x-ua": ua
                    },
                    data:{
                        "accountName":accountName,
                        "accountNo":accountNo
                    },
                    success: function (res) {
                        if(res.code==0){
                            refreshCapitalAccount();
                            window.location.href=base_url+"/putForward/zfbforward.html";
                        }else{
                            $("#message>span").html(res.message,1);
                            $("#message").removeClass("hide");
                            setTimeout(function () {
                                $("#message").addClass("hide");
                            },2000);
                        }
                    }
                });
            }
        });
    })
</script>
</body>
</html>